package org.jdu.dao;


import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;

import org.apache.log4j.Logger;
import org.jlu.logger.PrdLoggerFactory;

/**
 * Classe astratta per le'esecuzione dell'alter session su oracle.
 * @author epelli
 *
 */
public abstract class AbstractDBConnection implements DBConnection {

	/**
	 * Query per l'alter session
	 */
	public static final String ALTER_SESSION = "alter SESSION SET NLS_LANGUAGE='ITALIAN' "
			+ "NLS_TERRITORY = 'ITALY' "
			+ "NLS_CURRENCY='L.' "
			+ "NLS_ISO_CURRENCY='ITALY' "
			+ "NLS_NUMERIC_CHARACTERS=' ,.' "
			+ "NLS_CALENDAR = 'GREGORIAN' "
			+ "NLS_DATE_FORMAT='DD-MON-YY' "
			+ "NLS_DATE_LANGUAGE='ITALIAN' " 
			+ "NLS_SORT='WEST_EUROPEAN'";
	
	Logger log = PrdLoggerFactory.getInstance().getLogger("crp");
	
	/**
	 * Esegue l'alter session su db oracle.
	 * @param con
	 * @throws SQLException
	 */
	public final void alterSession(Connection con) throws SQLException{
		log.info("[AbstractDBConnection::alterSession] BEGIN");
		Statement stmt = con.createStatement();
		stmt.execute(AbstractDBConnection.ALTER_SESSION);
		stmt.close();
		log.info("[AbstractDBConnection::alterSession] END");
	}

}
